package org.study.bookmanager.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.study.bookmanager.io.reponse.RestBean;
import org.study.bookmanager.utils.JwtUtils;

import java.util.Date;

@RestController
@Slf4j
public class Debug {
    private final JwtUtils jwtUtils;

    public Debug(JwtUtils jwtUtils) {
        this.jwtUtils = jwtUtils;
    }

    @GetMapping("/now")
    public String Now() {
        long timestamp = new Date().getTime();
        return "当前时间戳为：" + timestamp;
    }

    @GetMapping("/ping")
    public String Ping(){
        return "pong";
    }

    @GetMapping("/jwt")
    public String getJwt(){
        String token=JwtUtils.createJWT(JwtUtils.createClaims("test"));
        return RestBean.success(token);
    }
}
